﻿
#region Copyright & License
// --------------------------
// Copyright 2008 Daniel Gray
// --------------------------
// This file is part of Kale.
//
// Kale is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Kale is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with Kale.  If not, see <http://www.gnu.org/licenses/>.
#endregion
#region File details
// --------------------------------------------------------
// Filename          : DiskNodesAssertionHelper.cs
// Author            : Daniel Gray
// Created           : 15/04/2008
// --------------------------------------------------------
#endregion
            
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.IO;

namespace Kale.Core.UnitTests
{
   public class DiskNodesAssertionHelper
   {
      private static void AssertNode(IImageNode node, NodeType type, string name, NodeSource source, string store, string path, string fullPath)
      {
         Assert.IsNotNull(node);
         Assert.AreEqual(type, node.NodeType);
         Assert.AreEqual(name, node.Name);
         Assert.AreEqual(source, node.NodeId.Source);
         Assert.AreEqual(store, node.NodeId.Store);
         Assert.AreEqual(path, node.NodeId.Path);
         if (!string.IsNullOrEmpty(fullPath))
         {
            Assert.AreEqual(Path.GetFullPath(fullPath), node.NodeInformation.FullName);
         }
         else
         {
            Assert.IsNull(node.NodeInformation);
         }
      }

      public static void AssertStore1Node(IImageNode node)
      {
         AssertNode(node, NodeType.Folder, "Store1", NodeSource.Disk, "Store1", string.Empty, "Store1Path");
      }

      public static void AssertStore2Node(IImageNode node)
      {
         AssertNode(node, NodeType.Folder, "Store2", NodeSource.Disk, "Store2", string.Empty, "Store2Path");
      }

      public static void AssertFolder1_1Node(IImageNode node)
      {
         AssertNode(node, NodeType.Folder, "Folder1.1", NodeSource.Disk, "Store1", "Folder1\\Folder1.1", "Store1Path\\Folder1\\Folder1.1");
      }

      public static void AssertFolder1_2Node(IImageNode node)
      {
         AssertNode(node, NodeType.Folder, "Folder1.2", NodeSource.Disk, "Store1", "Folder1\\Folder1.2", "Store1Path\\Folder1\\Folder1.2");
      }

      public static void AssertFile102_0082Node(IImageNode node)
      {
         AssertNode(node, NodeType.File, "102_0082.JPG", NodeSource.Disk, "Store1", "Folder1\\102_0082.JPG", "Store1Path\\Folder1\\102_0082.JPG");
      }

      public static void AssertFile102_0083Node(IImageNode node)
      {
         AssertNode(node, NodeType.File, "102_0083.JPG", NodeSource.Disk, "Store1", "Folder1\\102_0083.JPG", "Store1Path\\Folder1\\102_0083.JPG");
      }

      public static void AssertFile1DSC_1906Node(IImageNode node)
      {
         AssertNode(node, NodeType.File, "DSC_1906.JPG", NodeSource.Disk, "Store1", "Folder1\\Folder1.1\\DSC_1906.JPG", "Store1Path\\Folder1\\Folder1.1\\DSC_1906.JPG");
      }

      public static void AssertFile102_0086Node(IImageNode node)
      {
         AssertNode(node, NodeType.File, "102_0086.JPG", NodeSource.Disk, "Store1", "Folder1\\102_0086.JPG", "Store1Path\\Folder1\\102_0086.JPG");
      }

      public static void AssertFolder1Node(IImageNode node)
      {
         AssertNode(node, NodeType.Folder, "Folder1", NodeSource.Disk, "Store1", "Folder1", "Store1Path\\Folder1");
      }

      public static void AssertFolder2Node(IImageNode node)
      {
         AssertNode(node, NodeType.Folder, "Folder2", NodeSource.Disk, "Store1", "Folder2", "Store1Path\\Folder2");
      }

      public static void AssertFolder1ChildNodes(IImageNode[] nodes)
      {
         Assert.AreEqual(5, nodes.Length);

         AssertFolder1_1Node(nodes[0]);
         AssertFolder1_2Node(nodes[1]);
         AssertFile102_0082Node(nodes[2]);
         AssertFile102_0083Node(nodes[3]);
         AssertFile102_0086Node(nodes[4]);
      }

      public static void AssertFolder1_1ChildNodes(IImageNode[] nodes)
      {
         Assert.AreEqual(1, nodes.Length);
         AssertFile1DSC_1906Node(nodes[0]);
      }

      public static void AssertStore1ChildNodes(IImageNode[] nodes)
      {
         Assert.AreEqual(2, nodes.Length);
         AssertFolder1Node(nodes[0]);
         AssertFolder2Node(nodes[1]);
      }

      public static void AssertDiskStoreChildNodes(IImageNode[] nodes)
      {
         Assert.AreEqual(2, nodes.Length);
         AssertStore1Node(nodes[0]);
         AssertStore2Node(nodes[1]);
      }
   }
}
